import Vue from 'vue'
import Vuex from 'vuex'
import cinemas from './actions'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    title: '神影电影',
    cinemas: [],
  },
  mutations: {
    setTitle(state, title){
        state.title = title
    },
    setCinemas(state, cinemas){
        state.cinemas = cinemas.data
    }
  },
  actions: {
    getCinemas(context) {
      cinemas.getCinemas().then((data) =>{
        context.commit("setCinemas", data)
      } )
    }
  }
})